import sqlite3


def printCookies(cookiesDB):
    try:
        conn = sqlite3.connect(cookiesDB)
        c = conn.cursor()
        c.execute('SELECT host, name, value FROM moz_cookies')
        print('\n[*] -- Found Cookies --')
        for row in c.fetchall():
            host = str(row[0])
            name = str(row[1])
            value = str(row[2])
            # 注意在 Host 和 host 之间，以及 Cookie 和 name 之间添加了空格
            print('[+] Host: ' + host + ', Cookie: ' + name + ', Value: ' + value)
    except Exception as e:
        if 'encrypted' in str(e):
            print('\n[*] Error reading your cookies database.')
            print('[*] Upgrade your Python-Sqlite3 Library or check your database path.')
        else:
            # 打印出具体的错误信息，以便调试
            print(f'\n[*] An error occurred: {e}')

        # 注意确保文件路径是正确的，并且 Firefox 没有在运行时锁定该数据库


printCookies(r"C:\Users\yangchen\AppData\Roaming\Mozilla\Firefox\Profiles\lkcrh8j5.default-release\cookies.sqlite")